package com.xjm.ips.service;

import com.xjm.ips.entity.AjaxJson;
import com.xjm.ips.entity.Position;
import com.xjm.ips.mapper.PositionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PositionService {
    @Autowired
    PositionMapper positionMapper;

    //获取所有的职位信息
    public List<Position> getAllPositions() {
        return  positionMapper.getAllPositions();
    }

    /**
     * 添加职位信息
     * @param position
     * @return
     */
    public Integer addPositon(Position position) {
        position.setEnabled(true);
        position.setCreateDate(new Date());
        return positionMapper.insertSelective(position);//逆向工程中提供的动态新增方法
    }

    /**
     * 更新职位信息
     * @param position
     * @return
     */
    public Integer updatePosition(Position position) {
        return positionMapper.updateByPrimaryKeySelective(position);//动态更新
    }

    /**
     * 根据传入的Id删除对应的职位信息
     * @param id
     * @return
     */
    public Integer deletePositionById(Integer id) {
        return positionMapper.deleteByPrimaryKey(id);//根据id删除职位信息
    }

    /**
     * 批量删除职位信息
     * @param ids
     * @return
     */
    public Integer deletePositionsByIds(Integer[] ids) {
        return positionMapper.deletePositionsByIds(ids);
    }
}
